// import { UrlLink } from '../editor';

export interface Weixin {
  wx_id?: number;
  /**
   * @name 渠道类型
   * @num 1 微信公众号
   * @num 2 微信小程序
   * @num 3 h5 手机号注册
   */
  wx_type?: 1 | 2 | 3;
  shop_id?: number;
  appid?: string;
  appsecret?: string;
  nick_name?: string;
  head_img?: string;
  service_type_info?: number;
  verify_type_info?: number;
  user_name?: string;
  principal_name?: string;
  alias?: string;
  qrcode_url?: string;
  business_info?: string;
  func_info?: string;
  token?: string;
  mch_id?: number;
  partner_key?: string;
  create_time?: number;
  update_time?: number;
  encodingAESKey?: string;
  is_encoding?: number;
  refresh_token?: string;
  miniprograminfo?: string;
  upload_version?: string;
  auditid?: number;
  audit_version?: string;
  audit_time?: object;
  audit_result?: object;
  open_appid?: string;
  is_auth?: number;
  auth_change_at?: number;
  weixin_menu?: string | WeixinMenu;
}

export interface WeixinOpen {
  wo_id?: number;
  shop_id?: number;
  open_appid?: string;
  wx_id?: number;
  wx_appid?: string;
  wxapp_id?: number;
  wxapp_appid?: string;
  create_time?: number;
}

export interface WeixinMenu {
  button: WeixinMenuButton[];
}

export interface WeixinMenuButton {
  type: 'view' | 'click' | 'miniprogram';
  name: string;
  key?: string;
  url?: string;
  appid?: string;
  pagepath?: string;
  // url_obj?: UrlLink;
  sub_button?: WeixinMenuButton[];
}

/**
 * 网页授权返回值
 */
export interface WeixinOauthProfile {
  
}

/**
 * 模板消息
 */
export interface ITemplateMessage {
  SHOP_TRADE_NOTICE: ITemplateMessageItemShopTradeNotice;
  SHOP_IM_NOTICE: ITemplateMessageItemShopImNotice;
}

export enum EnumTemplateMessageName {
  SHOP_TRADE_NOTICE = 'SHOP_TRADE_NOTICE',
  SHOP_IM_NOTICE = 'SHOP_IM_NOTICE'
}

interface ITemplateMessageItemShopTradeNotice {
  template_id: string;
  buildData: (
    trade_no: string,
    buyer_nick: string,
    price: string,
    title: string,
    end_time: string,
    remark?: string
  ) => object;
}

interface ITemplateMessageItemShopImNotice {
  template_id: string;
  buildData: (
    nickname: string,
    message: string,
    remark?: string
  ) => object;
}

export const templateMessage: ITemplateMessage = {
  /**
   * @name 工作台-新订单提醒
   * @param first {{first.DATA}}
   * @param keyword1 订单编号：{{keyword1.DATA}}
   * @param keyword2 客户昵称：{{keyword2.DATA}}
   * @param keyword3 订单价格：{{keyword3.DATA}}
   * @param keyword4 订单标题：{{keyword4.DATA}}
   * @param keyword5 订单截止时间：{{keyord5.DATA}}
   * @param remark {{remark.DATA}}
   */
  SHOP_TRADE_NOTICE: {
    template_id: 'eTN9L-fL3R7aWFCvIrBgYQXJ5IvSp8yyU01M7R3Zc_M',
    buildData: (
      trade_no,
      buyer_nick,
      price,
      title,
      end_time,
      remark?,
    ): object => {
      return {
        first: {
          value: '您好，您收到了一个新订单，请尽快接单处理',
          color: '#173177',
        },
        keyword1: {
          value: trade_no,
          color: '#173177',
        },
        keyword2: {
          value: buyer_nick,
          color: '#173177',
        },
        keyword3: {
          value: price,
          color: '#173177',
        },
        keyword4: {
          value: title,
          color: '#173177',
        },
        keyword5: {
          value: end_time,
          color: '#173177',
        },
        remark: {
          value: '点击卡片查看订单',
          color: '#173177',
        },
      };
    }
  },
  /**
   * @name 工作台-用户咨询提醒
   * @param first {{first.DATA}}
   * @param keyword1 用户名称：{{keyword1.DATA}}
   * @param keyword2 咨询内容：{{keyword2.DATA}}
   * @param remark {{remark.DATA}}
   */
  SHOP_IM_NOTICE: {
    template_id: 'K0Oj5VPWEcuF8efFLkjOh6ASrqDL08PszkaHub9L88Q',
    buildData: (
      nickname,
      message,
      remark
    ): object => {
      return {
        first: {
          value: '您好，有客户咨询问题',
          color: '#173177',
        },
        keyword1: {
          value: nickname,
          color: '#173177',
        },
        keyword2: {
          value: message,
          color: '#173177',
        },
        remark: {
          value: remark || '请打开电脑版工作台回复信息',
          color: '#173177',
        },
      };
    }
  }
};
